local skill = fk.CreateSkill{
  name = "tea__fenpan",
}
---@type ActiveSkillSpec
local fenpan = {
  anim_type = "offensive",
  min_target_num = 1,
  card_filter = Util.FalseFunc,
  mute = true,
  target_filter = function(self, player, to_select, selected)
    return #selected == 0 or #selected[1]:getCardIds("h") == #to_select:getCardIds("h")
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(skill.name, Player.HistoryPhase) == 0
  end,
  on_use = function(self, room, effect)
    local player = effect.from
    room:notifySkillInvoked(player, skill.name, "offensive")
	  player:broadcastSkillInvoke(skill.name, table.random({1, 2}))
    local targets = effect.tos
    room:sortByAction(targets)
    local card = Fk:cloneCard("fire_attack")
    local use = {
      from = player,
      tos = targets,
      card = card,
      extraUse = true,
      extra_data = {tea__fenpan = true},
    }
    room:useCard(use)
    if table.find(targets, function(p)
      return p.dead
    end) and not player.dead then
      room:notifySkillInvoked(player, skill.name, "negative")
	    player:broadcastSkillInvoke(skill.name, 3)
      if #player:getCardIds("he") > 1 then
        local cids = room:askToDiscard(player, {
          min_num = 2,
          max_num = 2,
          skill_name = skill.name,
          include_equip = true,
          prompt = "#tea__fenpan-discard",
        })
        if #cids ~= 2 then
          room:loseHp(player, 1, skill.name)
        end
      else
        room:loseHp(player, 1, skill.name)
      end
    end
  end,
}
skill:addEffect("active", fenpan)
return skill